<?php 
	/*
	 * changes connection from mysql to using mysqli or PDO for a better next time
	 * settings -> isinya connect + settings global yang dibutuhkan untuk KRS-an
	*/

	if (!mysql_ping($conn)) {
		$conn = mysql_connect("localhost","root","");
		//Lost connection;
	}
	// $mysqli = new mysqli("localhost", "root", "", "uwika_krs");
	try {
		$pdo = new PDO('mysql:host=localhost;dbname=uwika_krs_alpha', 'root', '');
	} catch (PDOException $e) {
		print "Error!: " . $e->getMessage() . "<br/>";
		die();
	}
	
	/*
	if (!mysql_ping($conn)) {
		$conn=mysql_connect("localhost","uwika_krs","l14n54putr1");
		//Lost connection;
	}
	// $mysqli = new mysqli("localhost", "root", "", "uwika_krs");
	try {
		$pdo = new PDO('mysql:host=localhost;dbname=uwika_krs', 'uwika_krs', 'l14n54putr1');
	} catch (PDOException $e) {
		print "Error!: " . $e->getMessage() . "<br/>";
		die();
	}
	// $mysqli = new mysqli("localhost", "uwika_krs", "l14n54putr1", "uwika_krs");
	*/
	
	$sql = "SELECT id_meta_settings, meta_key, meta_value FROM settings_metadata WHERE meta_settings = :meta_settings";
	$stmt = $pdo->prepare($sql);
	$stmt->execute(array(':meta_settings' => 'SETTINGS.GLOBAL' ));
	while($_data = $stmt->fetch(PDO::FETCH_ASSOC)){
		$_global_settings[$_data['id_meta_settings']]->$_data['meta_key'] = $_data['meta_value'];
	}
	//var_dump($_global_settings);
	//var_dump($_global_settings['semester']);
	//echo $_global_settings['semester']->value;
?>